import axios from "axios";
let time = 0;
function getStopTime(){
    time = (time+300);
    return time;
}
async function stop(time:number) {
    await new Promise<void>((resolve)=>{setInterval(()=>{resolve()},time)})
    return;
}
let timer:NodeJS.Timeout|null;
//封装axios请求,防止每次请求时间的间隔时间过短.
export async function myRequest(url: string){
    console.log(time);
    if(timer){
       clearTimeout(timer)
    }
    await stop(getStopTime());
    timer = setTimeout(()=>{time = 0},5000)
    return  await axios.get(url)
}